/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MyClass;

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Image;
import javax.microedition.midlet.*;

/**
 * @author HuuTai_it
 */
public class Control extends MIDlet {

    private Display d;
    public GameManagement g;
    public int life = 3;
    public int difficulties = 1;
    public int scores = 0;
    public int level = 1;
    public boolean activeSound = true;
    
    public Control() throws Exception {
        
        d = Display.getDisplay(this);
    }
    
    public void startApp() {
        
        showMainMenu();
    }
    
    public void pauseApp() {
    }   
    public void destroyApp(boolean unconditional) {
        
        System.gc();
        notifyDestroyed();
    }   
    
    public void showMainMenu() {
        
        try {
            
            MainMenu mainMenu = new MainMenu(this);
            d.setCurrent(mainMenu);
        } 
        catch (Exception ex) {
            System.out.println(ex);
        }     
    }
    
    public void showAboutScreen() {
        
        try {
            
            About about = new About(this);
            about.start();
            d.setCurrent(about);
        } 
        catch (Exception ex) {
            System.out.println(ex);
        }
    }
    
    public void showHelpScreen() {
        
        try {
            
            Help help = new Help(this);
            d.setCurrent(help);
        } 
        catch (Exception ex) {
            System.out.println(ex);
        }   
    }
    
    public void showSettingScreen() {
        
        try {
            
            Setting setting = new Setting(this);
            d.setCurrent(setting);
        } 
        catch (Exception ex) {
            System.out.println(ex);
        }        
    }
    
    public void showHighScoresScreen() {
        
        try {
            
            HighScores highScores = new HighScores(this);
            d.setCurrent(highScores);
        } 
        catch (Exception ex) {
            System.out.println(ex);
        }   
    }
    
    public void showLoadingScreen(boolean startMode) {
        
        try {
            
            LoadingGame loadingGame = new LoadingGame(this, startMode);
            loadingGame.start();
            d.setCurrent(loadingGame);
        } 
        catch (Exception ex) {
            System.out.println(ex);
        }
    }
    
    public void newGame() {        
        
        try {
            
            g = new GameManagement(this);
            g.start();
            d.setCurrent(g);
        } 
        catch (Exception ex) {
            System.out.println(ex);
        }
    } 
    
    public void continueGame() {    
        
    }   
    
    public void exitGame() {        
            destroyApp(true);
    }
}
